home *** CD-ROM | disk | FTP | other *** search
- Path: asmobj.larc.nasa.gov!jaapjl
- From: jaapjl@asmobj.larc.nasa.gov (Lee Jaap)
- Newsgroups: comp.lang.c
- Subject: Re: What is '?' in C mean....?????
- Date: 26 Jan 1996 23:44:49 GMT
- Organization: probably not speaking for AS&M Inc
- Message-ID: <JAAPJL.96Jan26184450@asmobj.larc.nasa.gov>
- References: <4cgsa8$bm2@wumpus.cc.uow.edu.au> <4cvp4d$b6u@news.worldlinx.com>
- <ALUN.CHAMPION.96Jan10101442@g7240065.bridge.bst.bls.com>
- Reply-To: J Lee Jaap <jaapjl@asmsun.larc.nasa.gov>
- NNTP-Posting-Host: asmobj.larc.nasa.gov
- In-reply-to: Alun.Champion@bridge.bst.bls.com's message of 10 Jan 1996 15:14:42 GMT
-
- In article <ALUN.CHAMPION.96Jan10101442@g7240065.bridge.bst.bls.com> Alun.Champion@bridge.bst.bls.com (Alun Champion) writes:
- |>In article <4cvp4d$b6u@news.worldlinx.com> stupy@freenet.durham.org (Steve Tupy) writes:
- |>: PAOPENG THEERADECH (tp86@wumpus.cc.uow.edu.au) wrote:
- |>
- |>:: Hello to all.
- |>:: I got something here to ask you guys. I saw some symbol like "?" be
- |>:: used in some codes. I don't understand what does it mean. I tried to read some
- |>:: text books but I still cannot find the detail about "?". The codes that I saw
- |>:: are;
- |>:: max = x>y ? x:y;
- |>::
- |>:: and
- |>
- |>:: printf("%d", x>y ? x:y);
- |>
- |>: It tells you that an evaluation is about to happen. If x>y then max = x, if
- |>: x>y == 0 then max = y. The first value left of the colon is applied only if
- |>: it evaluates to 1, else the right side is applied.
- |>
- |>That should really be: The first value left of the colon is applied
- |>if the expression doesn't evaluate to 0, else the right side is applied.
- |>Any non-zero value will cause the left hand side to be evaluated, in C
- |>anything non-zero is true ;')
-
- Any decent C book will describe the ternary operator or the
- conditional expression operator.
- --
- J Lee Jaap <JaapJL@ASMSun.LaRC.NASA.Gov> +1 804/865-7093
- employed by, not necessarily speaking for,
- AS&M Inc, Hampton VA 23666-1340
-